import java.util.*;
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Utility class to help using the log.
 */
public class SkeletonHelper {
  public static int indent = 0;
  public static Integer objectCounter = 0;

  /**
   * Increases the indentation by one unit (2 spaces)
   */
  public static void IncreaseIndent()
  {
    indent++;
  }

  /**
   * Decreases the indentation by one unit (2 spaces)
   */
  public static void DecreaseIndent()
  {
    if (indent > 0)
      indent--;
  }

  /**
   * Retrieves a unique identifier for the caller.
   * @return The ID returned.
   */
  public static int GetObjectID()
  {
    return objectCounter++;
  }

  /**
   * Writes a line to the log using the indentation specified.
   * @param s The string to be written
   */
  public static void WriteLogLine(String s)
  {
    String temp = "";
    for (int i = 0; i < indent; i++)
      temp += "  ";
    System.out.println(temp + s);
  }

  /**
   * Writes a string to the log using the specified indent
   * @param s the string to be written
   */
  public static void WriteLogString(String s)
  {
    String temp = "";
    for (int i = 0; i < indent; i++)
      temp += "  ";
    System.out.print(temp + s);
  }

  /**
   * Write a function begin line to the console and increases the indent
   * @param entitytype the entity whose function is called
   * @param funcname the function called
   */
  public static void FunctionBegin(Integer objectID, String entitytype, String funcname)
  {
    WriteLogLine("> [" + objectID.toString() + "] " + entitytype + "." + funcname);
    IncreaseIndent();
  }

  /**
   * Indicates a functions end on the log and decreases the indent
   * @param entitytype the entity whose function just ended
   * @param funcname the function that ended
   */
  public static void FunctionEnd(Integer objectID, String entitytype, String funcname)
  {
    DecreaseIndent();
    WriteLogLine("< [" + objectID.toString() + "] " + entitytype + "." + funcname);
  }

  /**
   * Indicates a functions end on the log and decreases the indent
   * @param entitytype the entity whose function just ended
   * @param funcname the function that ended
   * @param ret the value returned
   */
  public static void FunctionEnd(Integer objectID, String entitytype, String funcname, String ret)
  {
    DecreaseIndent();
    WriteLogLine("< [" + objectID.toString() + "] " + entitytype + "." + funcname + ":" + ret);
  }

  public static String Ask(String question, String answers)
  {
    WriteLogLine("Q " + question);
    WriteLogLine("A " + answers);
    WriteLogString("? ");

    Scanner in = new Scanner(System.in);
    return in.next();
  }

}
